home *** CD-ROM | disk | FTP | other *** search
- package Local.Game.World
- {
- import flash.geom.Matrix;
-
- public class CAngle
- {
-
- public static const mDirectionIndexes:Object = {
- "E":0,
- "SE":1,
- "S":2,
- "SW":3,
- "W":4,
- "NW":5,
- "N":6,
- "NE":7
- };
-
- public static const bNE:int = 128;
-
- public static const SEARCHES4:Object = {
- "E":["E","N","S","W"],
- "S":["S","W","E","N"],
- "W":["W","S","N","E"],
- "N":["N","E","W","S"]
- };
-
- public static const bE:int = 1;
-
- public static const mEast:Object = {
- "mDirection":0,
- "mName":"E",
- "mNeighbour":"nEast",
- "mBits":bE,
- "mDelta":new CPosition(1,0),
- "mSubDelta":new CPosition(1 / 2,0)
- };
-
- public static const bNW:int = 32;
-
- public static const mDirectionNeighbours:Array = ["nEast","nSouthEast","nSouth","nSouthWest","nWest","nNorthWest","nNorth","nNorthEast"];
-
- public static const bS:int = 4;
-
- public static const mDirections4:Array = ["E","S","W","N"];
-
- public static const bSE:int = 2;
-
- public static const mNorthEast:Object = {
- "mDirection":7,
- "mName":"NE",
- "mNeighbour":"nNorthEast",
- "mBits":bNE,
- "mDelta":new CPosition(1,-1),
- "mSubDelta":new CPosition(1 / 2,-1 / 2)
- };
-
- public static const mDirections8:Array = ["E","SE","S","SW","W","NW","N","NE"];
-
- private static const negDirStack:Array = [0,-1,1,-2,2,-3,3,4];
-
- public static const bS_E:int = bE | bS;
-
- private static const MAXMASK:Number = 4294967295;
-
- private static const CONVRAD:Number = §§pop();
-
- private static const CONVRADM:Number = 1 / CONVRAD;
-
- public static const bSW:int = 8;
-
- public static const mSouthWest:Object = {
- "mDirection":3,
- "mName":"SW",
- "mNeighbour":"nSouthWest",
- "mBits":bSW,
- "mDelta":new CPosition(-1,1),
- "mSubDelta":new CPosition(-1 / 2,1 / 2)
- };
-
- public static const bW:int = 16;
-
- public static const mWest:Object = {
- "mDirection":4,
- "mName":"W",
- "mNeighbour":"nWest",
- "mBits":bW,
- "mDelta":new CPosition(-1,0),
- "mSubDelta":new CPosition(-1 / 2,0)
- };
-
- public static const bN:int = 64;
-
- public static const bN_W:int = bW | bN;
-
- public static const mNorth:Object = {
- "mDirection":6,
- "mName":"N",
- "mNeighbour":"nNorth",
- "mBits":bN,
- "mDelta":new CPosition(0,-1),
- "mSubDelta":new CPosition(0,-1 / 2)
- };
-
- public static const mDirectionNames:Array = ["E","SE","S","SW","W","NW","N","NE"];
-
- public static const mSouth:Object = {
- "mDirection":2,
- "mName":"S",
- "mNeighbour":"nSouth",
- "mBits":bS,
- "mDelta":new CPosition(0,1),
- "mSubDelta":new CPosition(0,1 / 2)
- };
-
- public static const bS_W:int = bW | bS;
-
- public static const mNorthWest:Object = {
- "mDirection":5,
- "mName":"NW",
- "mNeighbour":"nNorthWest",
- "mBits":bNW,
- "mDelta":new CPosition(-1,-1),
- "mSubDelta":new CPosition(-1 / 2,-1 / 2)
- };
-
- public static const mDirectionNameToNeighbour:Object = {
- "E":"nEast",
- "SE":"nSouthEast",
- "S":"nSouth",
- "SW":"nSouthWest",
- "W":"nWest",
- "NW":"nNorthWest",
- "N":"nNorth",
- "NE":"nNorthEast"
- };
-
- public static const bN_E:int = §§pop();
-
- private static const posDirStack:Array = [0,1,-1,2,-2,3,-3,4];
-
- public static const bESNW:int = §§pop() | §§pop();
-
- public static const mSouthEast:Object = {
- "mDirection":1,
- "mName":"SE",
- "mNeighbour":"nSouthEast",
- "mBits":bSE,
- "mDelta":new CPosition(1,1),
- "mSubDelta":new CPosition(1 / 2,1 / 2)
- };
-
- public static const mSearchRH:Object = {
- "E":[mEast,mSouthEast,mNorthEast,mSouth,mNorth,mSouthWest,mNorthWest,mWest],
- "SE":[mSouthEast,mSouth,mEast,mNorthEast,mSouthWest,mNorth,mWest,mNorthWest],
- "S":[mSouth,mSouthEast,mSouthWest,mEast,mWest,mNorthEast,mNorthWest,mNorth],
- "SW":[mSouthWest,mSouth,mWest,mSouthEast,mNorthWest,mNorth,mEast,mNorthEast],
- "W":[mWest,mNorthWest,mSouthWest,mNorth,mSouth,mSouthEast,mNorthEast,mEast],
- "NW":[mNorthWest,mNorth,mWest,mNorthEast,mSouthWest,mEast,mSouth,mSouthEast],
- "N":[mNorth,mNorthWest,mNorthEast,mWest,mEast,mSouthWest,mSouthEast,mSouth],
- "NE":[mNorthEast,mEast,mNorth,mSouthEast,mNorthWest,mSouth,mWest,mSouthWest]
- };
-
- public static const mDirectionByName:Object = {
- "E":mEast,
- "SE":mSouthEast,
- "S":mSouth,
- "SW":mSouthWest,
- "W":mWest,
- "NW":mNorthWest,
- "N":mNorth,
- "NE":mNorthEast
- };
-
- public static const mSearchLH:Object = {
- "E":[mEast,mNorthEast,mSouthEast,mNorth,mSouth,mNorthWest,mSouthWest,mWest],
- "SE":[mSouthEast,mEast,mSouth,mSouthWest,mNorthEast,mWest,mNorth,mNorthWest],
- "S":[mSouth,mSouthWest,mSouthEast,mWest,mEast,mNorthWest,mNorthEast,mNorth],
- "SW":[mSouthWest,mWest,mSouth,mNorthWest,mSouthEast,mEast,mNorth,mNorthEast],
- "W":[mWest,mSouthWest,mNorthWest,mSouth,mNorth,mNorthEast,mSouthEast,mEast],
- "NW":[mNorthWest,mWest,mNorth,mSouthWest,mNorthEast,mSouth,mEast,mSouthEast],
- "N":[mNorth,mNorthEast,mNorthWest,mEast,mWest,mSouthEast,mSouthWest,mSouth],
- "NE":[mNorthEast,mNorth,mEast,mNorthWest,mSouthEast,mWest,mSouth,mSouthWest]
- };
-
- public static const SEARCHES:Object = mSearchLH;
-
- public static const mDirectionByNeighbour:Object = {
- "nEast":mEast,
- "nSouthEast":mSouthEast,
- "nSouth":mSouth,
- "nSouthWest":mSouthWest,
- "nWest":mWest,
- "nNorthWest":mNorthWest,
- "nNorth":mNorth,
- "nNorthEast":mNorthEast
- };
-
- public static const mDirectionByIndex:Array = [mEast,mSouthEast,mSouth,mSouthWest,mWest,mNorthWest,mNorth,mNorthEast];
-
- private static const MAXANGLE:Number = §§pop();
-
- private static const CONVDEG:Number = MAXANGLE / 360;
-
- private static const CONVDEGM:Number = 1 / CONVDEG;
-
- {
- §§push(§§findproperty(bESNW));
- §§push(bE);
- §§push(bS);
- if(true)
- {
- §§push(§§pop() | §§pop() | bN);
- §§push(bW);
- }
- §§push(§§findproperty(bN_E));
- §§push(bE);
- if(true)
- {
- §§push(§§pop() | bN);
- }
- §§push(§§findproperty(MAXANGLE));
- §§push(4294967295);
- if(true)
- {
- §§push(§§pop() + 1);
- }
- §§push(§§findproperty(CONVRAD));
- §§push(MAXANGLE);
- if(true)
- {
- §§push(§§pop() / 2 / Math.PI);
- }
- }
-
- private var _Angle:int;
-
- public function CAngle(param1:int = 0)
- {
- if(true)
- {
- super();
- _Angle = param1;
- }
- }
-
- public static function AsCPosition(param1:CPosition) : CAngle
- {
- return new CAngle(Math.atan2(param1.y,param1.x) * CONVRAD);
- }
-
- public static function AsAngle256(param1:Number) : CAngle
- {
- §§push(CAngle);
- §§push(param1);
- if(true)
- {
- §§push(§§pop() * (1 << 24));
- }
- return new §§pop()(§§pop());
- }
-
- public static function AsXY(param1:Number, param2:Number) : CAngle
- {
- return new CAngle(Math.atan2(param2,param1) * CONVRAD);
- }
-
- public static function AsDirection(param1:int) : CAngle
- {
- return new CAngle(param1 << 29);
- }
-
- public static function DirectionDifference(param1:int, param2:int) : int
- {
- var _loc3_:int = 0;
- if(true)
- {
- §§push(param2);
- §§push(param1);
- if(true)
- {
- _loc3_ = §§pop() - §§pop();
- if(true)
- {
- §§push(_loc3_);
- §§push(3);
- if(true)
- {
- return §§pop() > §§pop() ? _loc3_ - 8 : (_loc3_ < -3 ? _loc3_ + 8 : _loc3_);
- }
- §§goto(addr41);
- }
- §§goto(addr34);
- }
- }
- §§goto(addr44);
- }
-
- public function get mAngleDEG() : Number
- {
- return _Angle * CONVDEGM;
- }
-
- public function get mDirectionName() : String
- {
- return mDirectionNames[mDirection];
- }
-
- public function get mDirectionNeighbourID() : String
- {
- return mDirectionNeighbours[mDirection];
- }
-
- public function Add(param1:CAngle) : void
- {
- if(true)
- {
- _Angle += param1._Angle;
- }
- }
-
- public function InvertOrientation() : void
- {
- mAngle += MAXMASK / 2;
- }
-
- public function get mAngle1() : Number
- {
- return mAngle256 / 256;
- }
-
- public function set mAngle(param1:int) : *
- {
- if(true)
- {
- _Angle = param1;
- }
- }
-
- public function get mMatrix() : Matrix
- {
- var _loc1_:Number = NaN;
- var _loc2_:Number = NaN;
- var _loc3_:Number = NaN;
- _loc1_ = mAngleRAD;
- _loc2_ = Math.sin(_loc1_);
- _loc3_ = Math.cos(_loc1_);
- return new Matrix(_loc3_,_loc2_,-_loc2_,_loc3_,0,0);
- }
-
- public function get mDirection() : int
- {
- §§push(_Angle);
- §§push(1);
- if(true)
- {
- §§push(§§pop() + (§§pop() << 28) >> 29);
- §§push(7);
- }
- return §§pop() & §§pop();
- }
-
- public function Copy(param1:CAngle) : void
- {
- _Angle = param1._Angle;
- }
-
- public function get mAngleRAD() : Number
- {
- return _Angle * CONVRADM;
- }
-
- public function set mAngleDEG(param1:Number) : *
- {
- if(true)
- {
- §§push(§§findproperty(_Angle));
- §§push(param1);
- if(true)
- {
- §§push(CONVDEG);
- if(true)
- {
- addr19:
- §§push(§§pop() * §§pop());
- §§push(MAXMASK);
- }
- §§pop()._Angle = §§pop() & §§pop();
- §§goto(addr22);
- }
- §§goto(addr19);
- }
- addr22:
- }
-
- public function set mAngle256(param1:Number) : *
- {
- if(true)
- {
- _Angle = param1 << 24;
- }
- }
-
- public function set mDelta(param1:CPosition) : void
- {
- if(true)
- {
- mAngleRAD = param1.mAngleRAD;
- }
- }
-
- public function set mAngleRAD(param1:Number) : *
- {
- _Angle = param1 * CONVRAD & MAXMASK;
- }
-
- public function Equals(param1:CAngle) : Boolean
- {
- return _Angle == param1._Angle;
- }
-
- public function Sub(param1:CAngle) : void
- {
- _Angle -= param1._Angle;
- }
-
- public function GetDelta(param1:Number = 1) : CPosition
- {
- var _loc2_:CPosition = null;
- _loc2_ = mDelta;
- if(param1 != 1)
- {
- _loc2_.normalize(param1);
- }
- return _loc2_;
- }
-
- public function get mDelta() : CPosition
- {
- var _loc1_:* = NaN;
- §§push(mAngleRAD);
- if(true)
- {
- §§push(§§pop());
- }
- _loc1_ = §§pop();
- return new CPosition(Math.cos(_loc1_),Math.sin(_loc1_));
- }
-
- public function set mDirection(param1:int) : *
- {
- §§push(§§findproperty(_Angle));
- §§push(param1);
- if(true)
- {
- §§push(§§pop() << 29);
- }
- §§pop()._Angle = §§pop();
- }
-
- public function get mAngle() : int
- {
- return _Angle;
- }
-
- public function get mAngle256Signed() : Number
- {
- §§push(_Angle);
- if(true)
- {
- §§push(1);
- if(true)
- {
- §§push(§§pop() << 23);
- }
- §§push(§§pop() + §§pop() >> 24);
- }
- return §§pop();
- }
-
- public function Scale(param1:Number) : void
- {
- _Angle *= param1;
- }
-
- public function get mAngle256() : Number
- {
- return _Angle + (1 << 23) >> 24 & 255;
- }
-
- public function get mDirectionObject() : Object
- {
- return mDirectionByIndex[mDirection];
- }
-
- public function TurnAngle(param1:CAngle) : CAngle
- {
- return new CAngle(param1._Angle - _Angle);
- }
-
- public function set mDirectionName(param1:String) : *
- {
- mDirection = mDirectionNames.indexOf(param1);
- }
-
- public function GetTurnCount(param1:CAngle) : int
- {
- var _loc2_:int = 0;
- if(true)
- {
- _loc2_ = mAngle / param1.mAngle;
- return _loc2_ >= 0 ? _loc2_ : int(-_loc2_);
- }
- §§goto(addr29);
- }
-
- public function Clone() : CAngle
- {
- return new CAngle(_Angle);
- }
- }
- }
-